package io.github.wanggit.antrpc.demos.circuit_breaker.circuit_breaker_provider.web;

import io.github.wanggit.antrpc.demos.circuit_breaker.circuit_breaker_provider.service.SwitchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("switch")
public class SwitchController {

    @Autowired
    private List<SwitchService> switchServices;

    @GetMapping("st")
    public String switchTo(@RequestParam("s") boolean success){
        switchServices.forEach(it -> it.switchTo(success));
        return "OK";
    }

}
